package com.situ.day11;

import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class SwingDemo2 {
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.setSize(500, 600);
		frame.setLocation(500,500);
		JPanel panel = new JPanel();
		frame.add(panel);
		frame.setTitle("66666");
		frame.setVisible(true);
		panel.setLayout(new GridLayout(3, 3));
		//创建控件
		JButton[] buttons = new JButton[9];
		for (int i = 0; i < buttons.length; i++) {
			JButton button = new JButton(Integer.toString((i + 1)));
			buttons[i] = button;
		}
		//添加控件
		for (int i = 0; i < buttons.length; i++) {
			panel.add(buttons[i]);
		}
		frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
	}
}
